//
//  LastCell.m
//  趣·美食
//
//  Created by dllo on 15/9/25.
//  Copyright (c) 2015年 金旭. All rights reserved.
//

#import "LastCell.h"


@interface LastCell ()

@property (nonatomic, strong) UILabel *label1;
@property (nonatomic, strong) UILabel *label2;
@property (nonatomic, strong) UILabel *label3;

@property (nonatomic, strong) NSArray *array;
@property (nonatomic, assign) BOOL isnight;

@end

@implementation LastCell



- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        
        self.array = @[@"热量", @"蛋白质", @"脂肪", @"淡水化合物", @"膳食纤维"];
        
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        
        self.label1 = [[UILabel alloc] init];
        [self.contentView addSubview:self.label1];
       
        
        self.label2 = [[UILabel alloc] init];
        [self.contentView addSubview:self.label2];
     
        
        self.label3 = [[UILabel alloc] init];
        [self.contentView addSubview:self.label3];
       
       
    }
    return self;
}

- (void)layoutSubviews {
    [super layoutSubviews];
    
    self.label1.frame = CGRectMake(ScreenWidth / 375.0 * 20, ScreenWidth / 375.0 * 10, ScreenWidth / 375.0 * 100, ScreenWidth / 375.0 * 30);
    
    self.label2.frame = CGRectMake(ScreenWidth / 375.0 * 190, ScreenWidth / 375.0 * 10, ScreenWidth / 375.0 * 100, ScreenWidth / 375.0 * 30);
    self.label2.font = [UIFont systemFontOfSize:15];
    
    self.label3.frame = CGRectMake(ScreenWidth / 375.0 * 300, ScreenWidth / 375.0 * 10, ScreenWidth / 375.0 * 75, ScreenWidth / 375.0 * 30);
    self.label3.font = [UIFont systemFontOfSize:15];
    self.label3.textColor = [UIColor lightGrayColor];
}

- (void)setDeModel:(GFDetialsModel *)deModel {
    if (_deModel != deModel) {
       
        _deModel = deModel;
    }
    
    switch (self.rowNumber) {
        case 0: {
            self.label1.text = self.array[0];
            if (![[self.deModel.ingredient objectForKey:@"calory"] isEqualToString:@""]) {
                self.label2.text = [NSString stringWithFormat:@"%@大卡", [self.deModel.ingredient objectForKey:@"calory"]];
            } else {
                self.label2.text = @"--";
            }
            
            if (![[self.deModel.lights objectForKey:@"calory"] isEqualToString:@""]) {
                
                self.label3.text = [self.deModel.lights objectForKey:@"calory"];
            } else {
                self.label3.text = @"";
            }
            
            break;
        }
        case 1: {
            self.label1.text = self.array[1];
            if (![[self.deModel.ingredient objectForKey:@"protein"] isEqualToString:@""]) {
                self.label2.text = [NSString stringWithFormat:@"%@克", [self.deModel.ingredient objectForKey:@"protein"]];
            } else {
                self.label2.text = @"--";
            }
            
            if (![[self.deModel.lights objectForKey:@"protein"] isEqualToString:@""]) {
                
                self.label3.text = [self.deModel.lights objectForKey:@"protein"];
            } else {
                self.label3.text = @"";
            }
            break;
        }
        case 2: {
            self.label1.text = self.array[2];
            if (![[self.deModel.ingredient objectForKey:@"fat"] isEqualToString:@""]) {
                self.label2.text = [NSString stringWithFormat:@"%@克", [self.deModel.ingredient objectForKey:@"fat"]];
            } else {
                self.label2.text = @"--";
            }
            
            if (![[self.deModel.lights objectForKey:@"fat"] isEqualToString:@""]) {
                
                self.label3.text = [self.deModel.lights objectForKey:@"fat"];
            } else {
                self.label3.text = @"";
            }
            break;
        }
        case 3: {
            self.label1.text = self.array[3];
            if (![[self.deModel.ingredient objectForKey:@"carbohydrate"] isEqualToString:@""]) {
                self.label2.text = [NSString stringWithFormat:@"%@克", [self.deModel.ingredient objectForKey:@"carbohydrate"]];
            } else {
                self.label2.text = @"--";
            }
            
            if (![[self.deModel.lights objectForKey:@"carbohydrate"] isEqualToString:@""]) {
                
                self.label3.text = [self.deModel.lights objectForKey:@"carbohydrate"];
            } else {
                self.label3.text = @"";
            }
            break;
        }
        case 4: {
            self.label1.text = self.array[4];
            if (![[self.deModel.ingredient objectForKey:@"fiber_dietary"] isEqualToString:@""]) {
                self.label2.text = [NSString stringWithFormat:@"%@克", [self.deModel.ingredient objectForKey:@"fiber_dietary"]];
            } else {
                self.label2.text = @"--";
            }
            
            if (![[self.deModel.lights objectForKey:@"fiber_dietary"] isEqualToString:@""]) {
                
                self.label3.text = [self.deModel.lights objectForKey:@"fiber_dietary"];
            } else {
                self.label3.text = @"";
            }
            break;
        }
        default: {
            
            break;
        }
    }

}

- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
